package com.mtw.bbs.userAdmin.feign;


import com.mtw.bbs.common.web.interceptor.BaseFeignInterceptor;
import com.mtw.bbs.userAdmin.pojo.dto.UserDto;
import com.mtw.bbs.common.core.vo.Result;
import com.mtw.bbs.userAdmin.pojo.form.UserRegisterForm;
import com.mtw.bbs.userAdmin.pojo.vo.UserInfoVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

import static com.mtw.bbs.common.core.constant.ApiPrefix.API_PREFIX_USER;

/**
 * User Feign接口类 ,fallback = UserClientFallback.class
 */
@FeignClient(name = "bbs-user",
        contextId = "userClientI",
        configuration = BaseFeignInterceptor.class,
        fallback = UserClientFallback.class)
public interface UserClient {


    /**
     * 获取用户信息
     */
    @ApiOperation(value = "获取用户详细信息", notes = "传入用户username")
    @GetMapping(API_PREFIX_USER + "/getUserVoByUsername")
    Result<UserInfoVo> getUserVoByUsername(@RequestParam("username") String username);

    /**
     * 获取用户信息
     */
    @ApiOperation(value = "获取用户信息", notes = "传入用户username")
    @GetMapping(API_PREFIX_USER + "/getUserInfoByUsername")
    Result<UserDto> getUserInfoByUsername(@RequestParam("username") String username);


    /**
     * 根据id获取用户信息
     */
    @ApiOperation(value = "获取用户信息", notes = "传入用户id")
    @GetMapping(API_PREFIX_USER + "/getUserInfoById")
    Result<UserDto> getUserInfoById(@RequestParam("userId") String userId);


    /**
     * 根据id集合获取用户信息
     */
    @ApiOperation(value = "获取用户信息", notes = "传入用户id集合")
    @PostMapping(API_PREFIX_USER + "/getUserInfoByIds")
    Result<List<UserDto>> getUserInfoByIds(@RequestBody String[] userIds);


    /**
     * 根据username和密码加载用户
     */
    @ApiOperation(value = "根据用户名或手机号及密码获取用户", notes = "传入用户username或手机号，密码必填")
    @GetMapping(API_PREFIX_USER + "/loadUserByPassword")
    Result<UserDto> loadUserByPassword(@RequestParam(name = "username") String username,
                                       @RequestParam(name = "password") String password);


    /**
     * 根据username加载用户
     */
    @ApiOperation(value = "根据用户名获取用户", notes = "传入用户username")
    @GetMapping(API_PREFIX_USER + "/loadUser")
    Result<UserDto> loadUserByUserName(@RequestParam("username") String username);


    /**
     * 根据mobile加载用户
     */
    @ApiOperation(value = "根据mobile获取用户", notes = "传入用户手机号")
    @GetMapping(API_PREFIX_USER + "/loadUserByMobile")
    Result<UserDto> loadUserByMobile(@RequestParam("mobile") String mobile);


}
